package com.gem.day06.extend1;

import java.time.LocalDate;

/**小时工*/
public class HourlyEmployee extends Employee {
	public static final double PAY_EACH_HOUR = 30;//时薪
	private int hours;//工作小时

	public HourlyEmployee() {
	}

	public HourlyEmployee(String name, LocalDate bithday, int hours) {
		super(name, bithday);
		this.hours = hours;
	}

	public int getHours() {
		return hours;
	}

	public void setHours(int hours) {
		this.hours = hours;
	}

	@Override
	public double getSalary(int month) {
		double salary = PAY_EACH_HOUR * hours;
		//判断超过160小时部分的工资
		if (hours - 160 > 0) {
			salary += (hours - 160) * PAY_EACH_HOUR * 0.5;
		}
		return super.getSalary(month) + salary;
	}

	@Override
	public String toString() {
		return super.toString() + ",工作小时数: " + hours + "," + PAY_EACH_HOUR + "元/小时.";
	}
}
